package cn.calm.xhtml.entity;

import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "tag", namespace = "http://www.calm.cn/extras/tag")
public class Tag {
	@XmlAttribute(name = "name")
	private String name;
	@XmlElement(name = "desc", namespace = "http://www.calm.cn/extras/tag")
	private String desc;
	@XmlAttribute(name = "hasContent")
	private boolean hasContent = true;
	@XmlElementRef
	private Set<Attr> attrs;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public Set<Attr> getAttrs() {
		return attrs;
	}

	public void setAttrs(Set<Attr> attrs) {
		this.attrs = attrs;
	}


	@Override
	public String toString() {
		return "Tag [name=" + name + ", desc=" + desc + ", hasContent="
				+ hasContent + ", attrs=" + attrs + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Tag other = (Tag) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public boolean isHasContent() {
		return hasContent;
	}

	public void setHasContent(boolean hasContent) {
		this.hasContent = hasContent;
	}

}
